<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
      <script type="text/javascript" src="../js/param.js"></script>
      <script type="text/javascript" src="../js/xcity.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
        <div class="layui-form">
            <input type="hidden" id="id">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>用户名
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="username"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
            <div class="layui-col-md6 layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red">*</span>权限
                </label>
                <div class="layui-input-inline">
                <select name="city" lay-verify="" id="userRole">
                    <option value="1">系统管理员</option>
                    <option value="2">普通员工</option>
                </select>
                </div>
            </div>

            <div class="layui-form-item">
              <label for="sex" class="layui-form-label">
                  <span class="x-red">*</span>性别
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="sex"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="phone" class="layui-form-label">
                  <span class="x-red">*</span>手机
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="phone"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">

              </div>
          </div>
          <div class="layui-form-item">
              <label for="email" class="layui-form-label">
                  <span class="x-red">*</span>邮箱
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="email"  required lay-verify="email"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
            <div class="x-body">
                <div class="layui-row">
                    <form class="layui-form layui-col-md12  layui-form-pane">
                        <div class="layui-form-item" id="x-city">
                            <label class="layui-form-label">选择城市</label>
                            <div class="layui-input-inline">
                                <select name="province" lay-filter="province" id="province">
                                    <option value="">请选择省</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="city" lay-filter="city" id="city">
                                    <option value="">请选择市</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="area" lay-filter="area" id="area">
                                    <option value="">请选择县/区</option>
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
            <div class="layui-form-item">
                <label for="address" class="layui-form-label">
                    <span class="x-red">*</span>详细地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="address"  required lay-verify="repass"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
          <div class="layui-form-item">
              <label for="update" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="" id="update" >
                  修改
              </button>
          </div>
          </div>
        </div>
    </div>
    <script>
        $(function () {
            var id = getParams("id");
            $("#id").val(id);
           $.ajax({
               url:'/Personnel/user/querybyuserid',
               type:'get',
               data:{"id":id},
               dataType:'json',
               success:function (d) {
                   layui.use(['form','code'], function(){
                       form = layui.form;

                       layui.code();

                       $('#x-city').xcity(d.province,d.city,d.area);
                   });
                   $("#username").val(d.name);
                   $("#userRole").val(d.role);
                   $("#sex").val(d.sex);
                   $("#phone").val(d.phone);
                   $("#email").val(d.email);
                   $("#address").val(d.address);
               }
           })
        })
      $("#update").click(function () {
          var id = getParams("id");
          var user={};
          user.id=id;
          user.name=$("#username").val();
          user.sex=$("#sex").val();
          user.phone=$("#phone").val();
          user.email=$("#email").val();
          user.address=$("#address").val();
          user.province=$("#province").val();
          user.city=$("#city").val();
          user.area=$("#area").val();
          user.role=$("#userRole").val();
           $.ajax({
               url:'/Personnel/user/updateInfo',
               type:'post',
               data:JSON.stringify(user),
               contentType:"application/json;charset=utf-8",
               dataType:'json',
               success:function (d) {
                    if(d.fig=="success"){
                        location.href="/Personnel/html/memberlist.html";
                    }
                    else{
                        alert("修改信息失败");
                    }
               }

           })
      })
  </script>
  </body>

</html>